<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*
      封装一个函数, 根据参数输出内容
    */

    function fn(n, m) {
      // code run here ...
    }

    /*[ [1, 2, 3, 4, 5]
[10, 9, 8, 7, 6]
[11, 12, 13, 14, 15]
[20, 19, 18, 17, 16]
[21, 22, 23, 24, 25]
[30, 29, 28, 27, 26]
[31, 32, 33, 34, 35] ]*/
    /*
      fn(5, 7)
        [                            [0-6]0
        [1  10  11  20  21  30  31]  00 10 20 30 40 50 60
        [2  9   12  19  22  29  32] 01 11 21 31 41 51 61
        [3  8   13  18  23  28  33] 02 12 22 32 42 52 62
        [4  7   14  17  24  27  34] 03 13 23 33 43 53 63
        [5  6   15  16  25  26  35] 04 14 24 34 44 54 64
        ]
        
    */

    // [1,2,3,4,5,6,7,8,9,10,...35]
    /* [[1,2,3,4,5]
    [6,7,8,9,10]   10,9,8,7,6
    [11,12,13,14,15]
    [16,17,18,19,20]20,19,18,17,16
    [21,22,23,24,25]
    [26,27,28,29,30]30,29,28,27,26
    [31,32,33,34,35] 
    ]*/

    let oldarrs = [];
    for(let i=1;i<=35;i++){
        oldarrs.push(i);
    }
    console.log(oldarrs); // 构建一个[1,2,3,4,5,..35]的数组

    // slice(0,5)
    // slice(5,10)
    // slice(10,15)
    // slice(15,20)
    // slice(20,25)
    // slice(25,30)
    // slice(30,35)
    // 每五个切割一次  每个割了后的得到的数组放到一个新的数组中
    const newarrs = [];
    for(let i=0;i<oldarrs.length;i+=5){
        newarrs.push(oldarrs.slice(i,i+5));
    }
    // console.log(newarrs);

    /* 
[1, 2, 3, 4, 5]
[6, 7, 8, 9, 10]
[11, 12, 13, 14, 15]
[16, 17, 18, 19, 20]
[21, 22, 23, 24, 25]
[26, 27, 28, 29, 30]
[31, 32, 33, 34, 35] 
    */


    // 反转 偶数个数组   二四六行反转 



    for(let i=0;i<newarrs.length;i++){
        if(i%2==1){
            newarrs[i].reverse();
        }
    }
    // console.log(newarrs);
/*[ [1, 2, 3, 4, 5]
[10, 9, 8, 7, 6]
[11, 12, 13, 14, 15]
[20, 19, 18, 17, 16]
[21, 22, 23, 24, 25]
[30, 29, 28, 27, 26]
[31, 32, 33, 34, 35] ]*/

// 上面是七行五列 

// 我们现在想得到五行七列的数组

const resarr = [];

for(let i=0;i<newarrs[0].length;i++){
    const arr = [];
    for(let j=0;j<newarrs.length;j++){
        arr.push(newarrs[j][i]);
    }
    resarr.push(arr);
}

console.log(resarr);

    </script>
</body>
</html>